home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Library
/
RoseWare - Network Support Library.iso
/
logbatch
/
home.arc
/
HOME.ASM
< prev
next >
Wrap
Assembly Source File
|
1988-05-20
|
5KB
|
203 lines
page 61, 132
title HOME - MAP a drive to user's SYS:MAIL directory
subttl macros and data
funct macro command
mov ah, command
int 21h
endm
Print macro asciiz
push si
lea si, asciiz
call print_asciiz
pop si
endm
page +
;***************************************************
;* Log Function 16: Get a Connection's Information *
;***************************************************
E3h16h_request struc
dw 2
db 16H
Connection db ?
E3h16h_request ends
E3h16h_reply struc
dw 62
UniqueID dd ?
dw ?
db 48 dup(?)
db 8 dup(?)
E3h16h_reply ends
;****************************************************
;* Directory Function 18: Allocate a Permanent Base *
;****************************************************
E2h12h_request struc
PacketLength dw ?
db 012h
db 0
DriveName db ?
SpecLength db ?
PathSpec db 'SYS:MAIL\'
directory db 8 dup(?)
E2h12h_request ends
E2h12h_reply struc
dw 2
NewBase db ?
AccessMask db ?
E2h12h_reply ends
page +
Code segment
assume CS:Code, DS:Code, ES:nothing, SS:nothing
org 0100H
Begin: jmp Check_args
db 'v 1.00'
db '(C)1988 Mark Halvin', 01AH
hex_digits db '0123456789ABCDEF'
BadArgs db 'Usage: HOME [drive:]', 07h, 0
MapError db 'Error mapping drive', 07h, 0
leading_zero db 0
even
getID_req E3h16h_request <>
even
getID_rep E3h16h_reply <>
even
MAPbase_req E2h12h_request <>
even
MAPbase_rep E2h12h_reply <>
subttl subroutines
page +
print_asciiz proc near ;print to StdOut the AsciiZ
push ax ; string pointed to by SI
push dx
push si
mov ah, 2 ;MS-DOS Character Output
l1: mov dl, [si] ;get output character
cmp dl, 0 ;is it a delimiter?
je l2 ;yes -- done.
int 21h ;call DOS to print character
inc si ;prepare for next character
jmp l1
l2: pop si
pop dx
pop ax
ret
print_asciiz endp
ax2hex proc near ;convert number in AX to
mov dx, ax ; ascii hex digits, stored
mov cl, 12 ; at DI. length returned in BL.
shr ax, cl
call al2hex
mov ax, dx
mov cl, 8
shr ax, cl
and ax, 000Fh
call al2hex
mov ax, dx
mov cl, 4
shr al, cl
and ax, 000Fh
call al2hex
mov ax, dx
and ax, 000Fh
call al2hex
ret
ax2hex endp
al2hex proc near ;converts one hex character in AL
mov si, ax
mov al, byte ptr[hex_digits + si] ;convert character
cmp leading_zero, 0 ;has a digit been printed?
jne l3 ; yes.
cmp al, '0' ;no, is this a zero?
je l4 ; yes, don't print it.
mov leading_zero, 0FFh ;no, set flag for next time.
l3: mov [di], al ;place output
inc bl
inc di
l4: ret
al2hex endp
subttl argument checking code
page +
home proc near
Check_args: mov si, 81h ;initial offset to parameters
scan: mov al, [si] ;get character
cmp al, 0Dh ;is it a CR?
je default ; yep -- no parameters, use default
cmp al, ' ' ;is it a space?
je again ; yep -- keep scanning
and al, 11011111b ;no, force it to upper case
cmp al, 'A'
jb arg_err ;too low (below A)
cmp al, 'Z'
ja arg_err ;too high (above Z)
mov MAPbase_req.DriveName, al ;save drive to map
jmp check_rest
again: inc si
jmp scan
check_rest: inc si ;make sure drive letter
cmp byte ptr[si], ':' ; has a colon after it.
jne arg_err
jmp Start
default: funct 19h ;Get Current Disk.
add al, 'A' ;convert it to ASCII
mov MAPbase_req.DriveName, al ;save it for later
subttl program code
page +
Start: funct 0DCh ;Get Station Number.
mov getID_req.Connection, al ; and save it
lea si, getID_req
lea di, getID_rep
funct 0E3h ;Get a Connection's Information.
;*******************************************
;* Translate binary UniqueID to ASCII hex. *
;* Keep length of ASCII ID string in BL. *
;*******************************************
lea di, MAPbase_req.directory ;destination of ID
xor bl, bl ;size of string
mov ax, word ptr[getID_rep.UniqueID]
xchg al, ah
call ax2hex ;convert AX to ASCII hex at DI
mov ax, word ptr[getID_rep.UniqueID + 2]
xchg al, ah
call ax2hex ;convert AX to ASCII hex at DI
add bl, 9 ;add ID string length to 'SYS:MAIL\'
mov MAPbase_req.SpecLength, bl ; and store it
add bl, 4 ;add up total reply packet length
xor bh, bh ;clear high byte
mov MAPbase_req.PacketLength, bx ; and store it
lea si, MAPbase_req
lea di, MAPbase_rep
funct 0E2h ;Allocate a Permanent Base.
jnc NoError
Print MapError ;error mapping base
mov al, 3 ;return ERRORLEVEL 3
jmp Terminate
arg_err: Print BadArgs ;argument error
mov al, 1 ;abort with ERRORLEVEL 1
jmp Terminate
NoError: xor al, al ;no ERRORLEVEL
Terminate: funct 4Ch ;Terminate Process.
home endp
Code ends
end Begin